home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / moveto.exe / MOVETO.DOC < prev   
Text File  |  1992-02-23  |  3KB  |  57 lines

  1.                                     MOVETO
  2.  
  3. Moveto is a simple function for moving a string of characters in a c program
  4. from one place to another.  Unlike memcpy or strncpy, this little function
  5. adds a fourth  parameter.  The explicit purpose of the extra parameter is to
  6. provide a character which, when detected in the source string, will stop the
  7. copying process prior to it itself being copied.  It may be assembled for a
  8. DOS or OS/2 program.  It will also function as a DLL function under OS/2 or
  9. Windows.  (Tested under OS/2 1.3 and 1.2 but not under windows.)
  10.  
  11. Under normal circumstances, the presence of a zero byte ('\0') in the source
  12. string will not have any effect on the operation of this function.  If you
  13. define the label "STOP_ON_ZERO_BYTE" (quotation marks not to be included)
  14. either in the source program or on the control statement call to MASM, two
  15. instructions will be inserted into the moveto function to stop the transfer
  16. after a zero byte has been transferred.
  17.  
  18. To use the moveto function:
  19.  
  20.     ptr = moveto(void *destination, void *source, int length, char stopper);
  21.  
  22. The characters are moved from source to destination until either the stopper
  23. character is found or length characters are transferred.  No checks are made
  24. for stack overflow, inadaquate array sizes etc.  You are on your own.  The
  25. source and destination array may overlap but undesired results can occur if
  26. you do not know what you are doing.  If the length parameter is zero, no bytes
  27. are moved and the program exits properly.
  28.  
  29. The return value of the function is a pointer to the NEXT byte in the
  30. destination string.  This was supplied so that a zero byte could be placed at
  31. this point.  If no characters are moved the return value of the function is
  32. a pointer to void *destination.
  33.  
  34. The program was written in MASM for execution speed.  It could have been written
  35. eaisily but with less efficiency in c.
  36.  
  37. You can assemble moveto by setting the argument string of MASM to
  38.  "/Mx {/Zi} /Dmemmodel={LARGE|SMALL|COMPACT|MEDIUM} {/DSTOP_ON_ZERO_BYTE}"
  39. if you need it.
  40.  
  41. You may notice that all source memory references are in brackets.  This is to
  42. maintain consistency with the Borland Turbo Assembler and also to symbolically
  43. stress that those operands are memory references.
  44.  
  45. Disclaimer:  This program is in the public domain.  It is not protected by
  46.     copyright or copywrong.  You are free to use it without any fees being
  47.     paid or special homage being laid on me.  I am not responsible for any
  48.     problems or damages which may occur from the use or non-use of this
  49.     program.  It seems dishwasher and microwave safe, non-toxic, safe for
  50.     children etc.  If you are learning assembly language it is probably
  51.     worth studying since it small enough to focus on each detail.  It also
  52.     shows how pointers and values are used in conjunction with a c program.
  53.  
  54.     Programmed By: A. L. Bender, M. D.
  55.                Bender Consulting
  56.     Released:      2/23/92
  57.